<?php

declare(strict_types=1);

namespace App\Request\Topic;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class TopicReplyRequest extends BaseCommonRequest
{
    public function authorize(): bool
    {
        return true;
    }

    protected array $scenes = [
        'reply' => ['topic_id', 'content'],
        'zan' => ['type', 'id'],
        'delete' => ['ids']
    ];

    public function rules(): array
    {
        // return [
        //     'id' => 'required',
        //     'topic_id' => 'required',
        //     'reply_uid' => 'required',
        //     'reply_id' => 'required',
        //     'content' => 'required',
        //     'ids' => 'required|array',
        // ];
        return [
            'reply' => [
                'topic_id' => 'required',
                'content' => 'required',
            ],
            'zan' => [
                'type' => 'required',
                'id' => 'required',
            ],
            'delete' => [
                'ids' => 'required|array',
            ],
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        $language = Context::get('language', 'en');
        if ($language == 'zh-cn') {
            return [
                'required' => ':attribute不能为空',
                'array' => ':attribute必须为数组'
            ];
        } elseif ($language == 'zh-hk') {
            return [
                'required' => ':attribute不能為空',
                'array' => ':attribute必須為數組'
            ];
        } else {
            return [
                'required' => ':attribute field is required.',
                'array' => ':attribute field must be array.'
            ];
        }

    }

}